<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>文本绘制</title>
  <style>
    canvas {
      border: 1px solid #000;
    }
  </style>
</head>

<body>
  <canvas id="myCanvas" width="600" height="600"></canvas>

  <script>
    const canvas = document.getElementById("myCanvas");
    const ctx = canvas.getContext("2d");

    // 绘制文字
    // 设置字体样式
    ctx.font = "30px 微软雅黑";
    // 文字对齐方式
    // ctx.textAlign = "center";
    ctx.fillText("你好你好, 我是微软雅黑样式的文字", 80, 100);
  </script>
</body>

</html>